var plugor.resizable = function(elem){
	var _resizeObj,_controlObj;
	self.resizePosition={}
	self.beginPoint={};
	self.endPoint={};
	var _thisDrag=self;
	var resizeWidthObj,resizeheightObj;
	
	var startPointX=0,endPointX=0,startPointY=0,endPointY=0;
	
	if(_resizeObj){
		resizeWidthObj=_resizeObj.children(".p-dialog");
		resizeheightObj=resizeWidthObj.children(".p-dialog-contentpane");
	}
	var dragMouseDownHandler=function(e){
		if(_resizeObj){
			resizeWidthObj=_resizeObj.children(".p-dialog");
			resizeheightObj=resizeWidthObj.children(".p-dialog-contentpane");
		}
		
		_thisDrag.resizePosition={
			"width":resizeWidthObj.width(),
			"height":resizeheightObj.height()
		}
		_thisDrag.beginPoint={
			"x":e.pageX,
			"y":e.pageY
		}
		
		$("body").css("cursor","nw-resize");
		// 注册事件(鼠标移动)
		$(document).bind("mousemove", dragMouseMoveHandler);
		// 注册事件(鼠标松开)
		$(document).bind("mouseup", dragMouseUpHandler);
		
		self.stopDefault(e)
		self.stopBubble(e)
		/*
		 * //取消事件的默认动作 if(e.preventDefault) e.preventDefault(); else
		 * e.returnValue = false;
		 */	}
	
	var dragMouseMoveHandler=function(e){
		self.stopDefault(e)
		self.stopBubble(e)
		_thisDrag.endPoint={
				"x":e.pageX,
				"y":e.pageY
			}
		// var dragobj=_resizeObj.find(".p-dialog-resizable-handle");
		if(_thisDrag.resizePosition.width<self.minWidth){
			_thisDrag.resizePosition.width=self.minWidth;
			startPointX=_controlObj.offset().left+_controlObj.width();
			// resizeWidthObj.css("width",_thisDrag.resizePosition.width+"px");
			// return;
		}else if(_thisDrag.resizePosition.width>self.maxWidth){
			_thisDrag.resizePosition.width=self.maxWidth;
			endPointX=_controlObj.offset().left+_controlObj.width();
			// resizeWidthObj.css("width",_thisDrag.resizePosition.width+"px");
			// return;
		}else if(_thisDrag.resizePosition.height<self.minHeight){
			_thisDrag.resizePosition.height=self.minHeight;
			startPointY = _controlObj.offset().top+ _controlObj.height();
			// resizeheightObj.css("height",_thisDrag.resizePosition.height+"px").children().css("height",_thisDrag.resizePosition.height+"px");
			// return;
		}else if(_thisDrag.resizePosition.height>self.maxHeight){
			_thisDrag.resizePosition.height=self.maxHeight;
			endPointY = _controlObj.offset().top + _controlObj.height();
			// resizeheightObj.css("height",_thisDrag.resizePosition.height+"px").children().css("height",_thisDrag.resizePosition.height+"px");
			// return;
		}
		
		// 判断鼠标是否在焦点位置
		if(e.pageX<startPointX && startPointX!=0){// ||
			// return false;
			_thisDrag.endPoint.x=startPointX;
		}else if( e.pageX>endPointX && endPointX!=0 ){
			_thisDrag.endPoint.x=endPointX;
		}
		
		if( e.pageY<startPointY && startPointY!=0){
			_thisDrag.endPoint.y=startPointY;
		}else if(e.pageY>endPointY && endPointY!=0){
			_thisDrag.endPoint.y=endPointY;
		}
		
		_thisDrag.resizePosition={
				"width":_thisDrag.resizePosition.width+(_thisDrag.endPoint.x-_thisDrag.beginPoint.x),
				"height":_thisDrag.resizePosition.height+(_thisDrag.endPoint.y-_thisDrag.beginPoint.y)
		}
		resizeWidthObj.css("width",_thisDrag.resizePosition.width+"px");
		resizeheightObj.css("height",_thisDrag.resizePosition.height+"px").children().css("height",_thisDrag.resizePosition.height+"px");
		_thisDrag.beginPoint=_thisDrag.endPoint;
	}
	var dragMouseUpHandler=function(e){
		$(document).unbind("mouseup");
		$(document).unbind("mousemove");
		/*
		 * //取消事件的默认动作 if(e.preventDefault) e.preventDefault(); else
		 * e.returnValue = false;
		 */$("body").css("cursor","default");
	}
	return{
		Register:function(resizeObj,controlObj){
			_controlObj=controlObj;
			_resizeObj=resizeObj;
			_controlObj.bind("mousedown",dragMouseDownHandler);
		}
	}
}